/*
 * 带图片带标题的块，新闻模块
 *
 *mainImg:图片路径
 *title：标题
 *date：日期
 * content：内容
 * */

'use strict';
var React = require('react');
class RePictureLiGroup extends React.Component {

    constructor(props) {
        super(props);
        this.renderContent = this.renderContent.bind(this);
        this.getSpecialClass=this.getSpecialClass.bind(this);
    }

    //渲染主体部分
    renderContent() {
        if(this.props.reData&&this.props.reData.length>0) {
            return this.props.reData.map((item, i)=> {
                return (
                    <div key={"RePictureLi"+i} className="RePictureLi_Container">
                        <div className="RepictureLi_Img">
                            <a target="_blank" href={item.href}><img src={item.mainImg}/></a>
                        </div>
                        <div className="RePictureLi_Message">
                            <div className="RePictureLi_TitleGroup">
                      <span className="RePictureLi_Title">
                           <a target="_blank" href={item.href}>{item.title}</a>
                      </span>
                      <span className="RePictureLi_Date">
                          <a target="_blank" href={item.href}>{item.date}</a>
                      </span>
                            </div>
                            <div className="RePictureLi_Content">
                                <a target="_blank" href={item.href}>{item.content}</a>
                            </div>
                        </div>
                    </div>);
            });
        }
    }

    //获取样式
    getSpecialClass(){
        if(this.props.reClass!=undefined){
            return "RePictureLiGroup_Container "+this.props.reClass;
        }
        else{
            return 'RePictureLiGroup_Container';
        }
    }

    render() {
        return (
            <div className={this.getSpecialClass()}>
                {this.renderContent()}
            </div>
        );
    }
}

module.exports = RePictureLiGroup;